package router

import (
	"encoding/gob"
	"github.com/gin-contrib/sessions"
	"github.com/gin-contrib/sessions/cookie"
	"github.com/gin-gonic/gin"
	"testGin/middleware"
	"testGin/model/mysql"
)



func Router(r *gin.Engine ){

	//处理session
	store := cookie.NewStore([]byte("secret"))
	// 设置session中间件，参数mysession，指的是session的名字，也是cookie的名字
	// store是前面创建的存储引擎，我们可以替换成其他存储引擎
	r.Use(sessions.Sessions("mysession", store))
	r.Use(middleware.CheckNode(r))
	gob.Register(mysql.Admins{})
	//加载api 路由
	IndexRouter(r)
	//加载前台路由
	ApiRouter(r)
}